<template>
  <div class="home">
    <!-- 导航栏 -->
    <div class="header w">
      <div class="logo">
        <img src="../assets/biaozhi.png" alt="" />
      </div>
      <div class="nav">
        <ul>
          <li><router-link to="/">首页</router-link></li>
          <li><router-link to="#">免费课程</router-link></li>
          <li><router-link to="#">项目实战</router-link></li>
          <li><router-link to="#">职业规划</router-link></li>
        </ul>
      </div>
      <div class="search">
        <input type="text" value="记得快忘得慢" />
        <button>搜索</button>
      </div>
      <div class="user">
        <router-link to="#">会员中心</router-link> |
        <router-link to="#">我的学习</router-link> |
        <router-link to="#">登录/注册</router-link>
      </div>
    </div>
    <!-- 导航栏结束 -->
    <!-- 主体部分开始 -->
    <div class="main">
      <div class="w">
        <!-- 头 -->
        <div class="main-header">
          <div class="first">
            <router-link to="/">
              首页<i class="el-icon-arrow-right" style="margin-left: 5px"></i>
            </router-link>
            <span style="margin-left: 5px">大学考试</span>
          </div>
        </div>
        <div class="main-body">
          <div class="third">
            <ul>
              <li><router-link to="#" class="a-active">精选</router-link></li>
              <li>
                <router-link to="#">考研</router-link>
              </li>
              <li>
                <router-link to="#">四六级</router-link>
              </li>
              <li>
                <router-link to="#">雅思</router-link>
              </li>
              <li>
                <router-link to="#">专四专八</router-link>
              </li>
              <li>
                <router-link to="#">专升本</router-link>
              </li>
              <li>
                <router-link to="#">英语提升</router-link>
              </li>
              <li>
                <router-link to="#">公务员</router-link>
              </li>
            </ul>
          </div>
          <div class="block">
            <el-carousel trigger="click" height="360px">
              <el-carousel-item v-for="b in block" :key="b.id">
                <img
                  :src="'http://localhost:3000/' + b.image"
                  alt="图片加载失败"
                />
              </el-carousel-item>
            </el-carousel>
          </div>
          <!-- 雅思 -->
          <div class="main-body-header">
            <h2>雅思</h2>
          </div>
          <div class="main-body-middle">
            <ul v-for="u in university" :key="u.id">
              <li>
                <img
                  :src="'http://localhost:3000/' + u.image"
                  alt="图片加载失败"
                />
                <router-link :to="{ path: u.path }"
                  ><h3>{{ u.title }}</h3></router-link
                >
                <div class="inf">时间：{{ u.time }}</div>
                <div class="main-body-bottom">
                  <span class="buy-count">{{ u.buycount }}</span>
                  <span class="price">{{ u.price }}</span>
                </div>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <!-- 主体结束 -->
    <!-- 底部开始 -->
    <div class="footer">
      <div class="w">
        <div class="title">
          <ul>
            <li><router-link to="#">关于我们</router-link></li>
            <li><router-link to="#">联系我们</router-link></li>
            <li><router-link to="#">帮助中心</router-link></li>
            <li><router-link to="#">客户服务</router-link></li>
            <li><router-link to="#">新手指南</router-link></li>
            <li><router-link to="#">合作机构</router-link></li>
            <li><router-link to="#">合作导师</router-link></li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      university: [],
      block: [],
    };
  },
  created() {
    this.queryUniversity();
    this.queryBlock();
  },
  methods: {
    queryUniversity() {
      this.axios
        .get(" http://localhost:3000/university")
        .then((response) => {
          this.university = response.data;
        })
        .catch((error) => {
          console.log(error);
        });
    },
    queryBlock() {
      this.axios
        .get(" http://localhost:3000/block")
        .then((response) => {
          this.block = response.data;
        })
        .catch((error) => {
          console.log(error);
        });
    },
  },
};
</script>
<style>
* {
  margin: 0;
  padding: 0;
}
.w {
  width: 1200px;
  margin: auto;
}
.header {
  height: 42px;
  /* 上下30 */
  margin: 30px auto;
}
/* 去除li样式 */
li {
  list-style: none;
}
/* 去除所有a链接下划线 */
a {
  text-decoration: none;
  color: #050505;
}
.logo {
  float: left;
  width: 198px;
  height: 42px;
}
.logo img {
  width: 198px;
  height: 42px;
}
.nav {
  float: left;
  margin-left: 10px;
}
.nav ul li {
  float: left;
}
.nav ul li a {
  display: block;
  height: 42px;
  /* 上下给0 左右给10 */
  padding: 0 10px;
  /* 垂直居中 */
  line-height: 42px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  color: #050505;
}
/* 鼠标划过 下划线 */
.nav ul li a:hover {
  border-bottom: 2px solid rgb(255, 63, 41);
  color: rgb(255, 63, 41);
}
.search {
  float: left;
  width: 412px;
  height: 42px;
  margin-left: 15px;
}
.search input {
  float: left;
  width: 320px;
  height: 40px;
  border: 1px solid rgb(255, 63, 41);
  /* 将边框右设为0 */
  border-right: 0;
  color: #bfbfbf;
  font-size: 14px;
  padding-left: 15px;
  border-radius: 5px 0 0 5px;
  /* 去除被点击时的黑框 */
  outline: none;
}
.search button {
  float: left;
  width: 70px;
  height: 42px;
  background-color: rgb(255, 63, 41);
  border: 0;
  font-size: 16px;
  color: #fff;
  cursor: pointer;
  border-radius: 0 5px 5px 0;
}
.user a {
  line-height: 42px;
  color: #050505;
}
.user a:hover {
  color: rgb(255, 63, 41);
}
/* 中间部分开始 */
.main {
  height: 1600px;
  background-color: rgb(242, 242, 242);
}
.main-header {
  height: 45px;
  /* background-color: pink; */
}

.main-header span {
  color: rgb(153, 153, 153);
}
.main-header .first {
  float: left;
  width: 170px;
  height: 40px;
  line-height: 40px;
  /* background-color: yellow; */
}

.main-body .third {
  height: 30px;
  /* background-color: red; */
}
.a-active {
  color: rgb(255, 63, 41) !important;
}
.main-body .third ul li {
  float: left;
  margin-left: 20px;
}
.main-body .third ul li a {
  color: rgb(102, 102, 102);
}
.main-body .third ul li a:hover {
  color: rgb(255, 63, 41);
}
/* 走马灯 */
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.block {
  margin-top: 20px;
}
/* 走马灯结束 */

.main-body-header {
  height: 45px;
}
.main-body-header h2 {
  float: left;
  margin-top: 50px;
  color: #333333;
}
.main-body-middle {
  width: 1220px;
  height: 310px;
  margin-top: 50px;
}
.main-body-middle ul li {
  float: left;
  width: 292px;
  height: 310px;
  margin-top: 15px;
  margin-left: 10px;
  border-radius: 10px;
  background-color: #fff;
}
.main-body-middle ul li img {
  width: 292px;
  height: 164.38px;
  border-radius: 5px 5px 0 0;
}
.main-body-middle ul li h3 {
  color: #333333;
  font-weight: 400;
  font-family: Arial, Helvetica, sans-serif;
  margin: 10px 20px 10px 20px;
}
.inf {
  font-family: Arial, Helvetica, sans-serif;
}
.main-body-bottom {
  width: 292px;
  height: 35px;
  margin: 14px 0 0;
  line-height: 35px;
  /* background-color: yellow; */
}
.main-body-bottom .buy-count {
  float: left;
  margin-left: 17px;
  color: #818a92;
}
.main-body-bottom .price {
  float: right;
  margin-right: 17px;
  font-size: 22px;
  color: #ff1d00;
}
.main-body-bottom .price-sell-out {
  float: right;
  margin-right: 17px;
  font-size: 22px;
  color: #b0b3b7;
}

/* 底部 */
.footer {
  height: 178px;
  background-color: rgb(71, 68, 67);
}
.footer ul li {
  float: left;
}
.footer ul li a {
  color: #fff;
  padding: 20px;
}
.footer .title {
  width: 800px;
  height: 30px;
  /* background-color: red; */
  padding-top: 30px;
}
.footer .title a:hover {
  border-bottom: 2px solid #fff;
}
</style>